<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <title>要素图层</title>
    <link rel="stylesheet" href="css/demo.css">
    <script src="js/configData.js"></script>


    <script src="libs/axios.min.js"></script>
    <script src="libs/httpService.js"></script>
    <script src="js/demo.js"></script>
</head>

<body>
<div id="map"></div>
<div class="opt_panel">
    <button onclick="addEleDev()">添加设备</button>
    <button onclick="removeEleDev()">删除设备</button>
    <br>
    <button onclick="onStartDraw()">开始框选(默认矩形)</button>
    <button onclick="onEndDraw()">停止框选</button>
    <br>
    <button onclick="onStartSnap()">开始捕捉</button>
    <button onclick="onEndSnap()">停止捕捉</button>
</div>
<script>

    //示例说明：
    //该示例描述如何使用GridFeaturelayer进行大量设备渲染
    //【注：该示例适应的应用场景为1.用户不需要电网出图服务自动生成电网网架，2.用户根据自有业务数据进行绘制，3.无大量设备移动的场景】

    //自定义示例参数
    mapOptions = {
        zoom: 20,
        center: [116.00039232517923, 31.000224836526826]
    }


    //示例功能代码
    //要素图层
    var featureLayer
    //默认设备
    var testDatas
    //移除的设备
    var removedDevs = []

    function onStartDraw() {
        snapTool.disable()
        //框选工具开启后的操作方式为：1.点击地图确定第一个点，2.移动鼠标改变矩形大小,3.点击鼠标确定第二个点
        selectTool.enable()
    }

    //关闭框选工具
    function onEndDraw() {
        selectTool.disable(true)
    }

    //开启捕捉工具
    function onStartSnap() {
        selectTool.disable(true)
        snapTool.enable()
    }

    //关闭捕捉工具
    function onEndSnap() {
        snapTool.disable()
    }


    //添加设备
    function addEleDev() {
        if (removedDevs.length) {
            let dev = removedDevs.pop()
            testDatas.push(dev)
            featureLayer.addEleSymbols([dev])
        }
    }

    //移除设备
    function removeEleDev() {
        if (testDatas.length) {
            let dev = testDatas.pop()
            removedDevs.push(dev)
            featureLayer.removeEleSymbols([dev])
        }

    }


    function initPage() {
        map.setCenter([116, 31]); //设置地图中心点
        //创建要素图层
        featureLayer = new egisV2.layer.GridFeatureLayer({map: map})
        //添加本地设备:
        testDatas = [
            new egisV2.symbol.ElePointSymbol({
                devId: 'a10001',//oid，psrid
                devTypeId: '301000',//设备类型
                symbolId: "4020290",//符号ID
                symbolRotate: 20,//旋转角度
                symbolSize: 2,//大小
                symbolColor: '#ff0000',//颜色
                symbolOpacity: 1,//透明度
                symbolScalable: true,//缩放
                coordinates: [116, 31],//坐标
                attributes: {a: 1, b: 2}//其它信息
            })
            ,
            new egisV2.symbol.EleLineSymbol(
                {
                    devId: 'b20001',//oid，psrid
                    devTypeId: '35421985',//设备类型
                    symbolId: '2010010',//符号ID
                    symbolWidth: 30,//线宽
                    symbolColor: '#ff0000',//颜色
                    symbolOpacity: 1,//透明度
                    coordinates: [[[120.97012321587532,31.605035382503868],[120.97013281249393,31.605011109292622],[120.97013281249393,31.605011109292622],[120.97018818155695,31.605042506155133],[120.9702417728136,31.605072894944882],[120.9702417728136,31.605072894944882],[120.97069177016395,31.605479843439163],[120.97069177016395,31.605479843439163],[120.97114918694817,31.60589652381056],[120.97114918694817,31.60589652381056],[120.9714224610593,31.606049707369426],[120.9714224610593,31.606049707369426],[120.97176122843088,31.606300971247478],[120.97176122843088,31.606300971247478],[120.97159500845119,31.60498796702991],[120.97159500845119,31.60498796702991],[120.97150169194366,31.604821722567188],[120.97150169194366,31.604821722567188],[120.97129702178361,31.604645192981568],[120.97129702178361,31.604645192981568],[120.97109937890234,31.604527708718603],[120.97109937890234,31.604527708718603],[120.97094387312633,31.604438321650626],[120.97094387312633,31.604438321650626],[120.97074323758225,31.604337837923918],[120.97074323758225,31.604337837923918],[120.97054258095476,31.604237347836865],[120.97054258095476,31.604237347836865],[120.97034194809574,31.60413685895127],[120.97034194809574,31.60413685895127],[120.97027344749675,31.604095938469506],[120.97027344749675,31.604095938469506],[120.97028032356485,31.604052605862115]],[[120.9714224610593,31.606049707369426],[120.97176122843088,31.606300971247478]],[[120.97114918694817,31.60589652381056],[120.9714224610593,31.606049707369426]],[[120.9740879472593,31.603881494510578],[120.9742544582258,31.604426417420182]],[[120.9728499121397,31.603092012971505],[120.97339204768281,31.60337357201978],[120.97339204768281,31.60337357201978],[120.97368237965763,31.603499381784204],[120.97368237965763,31.603499381784204],[120.97390953070658,31.60358370870467],[120.97390953070658,31.60358370870467],[120.97394623811037,31.603564837667538],[120.97394623811037,31.603564837667538],[120.97401406457767,31.603600261351296],[120.97407630546064,31.60363276789659],[120.97407630546064,31.60363276789659],[120.97418756924036,31.603695837799094],[120.97418756924036,31.603695837799094],[120.97444578320534,31.603842095400886],[120.97444578320534,31.603842095400886],[120.97469191824159,31.60403723266735],[120.97469191824159,31.60403723266735],[120.97493773811287,31.604208867033446],[120.97493773811287,31.604208867033446],[120.97505819880226,31.604309705734074],[120.97505819880226,31.604309705734074],[120.97524840361318,31.60441439817198],[120.97524840361318,31.60441439817198],[120.97593639777713,31.60483944848609],[120.97593639777713,31.60483944848609],[120.97647302522192,31.605145601055785],[120.97647302522192,31.605145601055785],[120.97697098706405,31.605432400211914],[120.97697098706405,31.605432400211914],[120.97750937574308,31.605766038651087],[120.97750937574308,31.605766038651087],[120.97815384791222,31.606161864000992],[120.97815384791222,31.606161864000992],[120.97867081487814,31.6065093829137],[120.97867081487814,31.6065093829137],[120.9789136651832,31.606219808184623],[120.9789136651832,31.606219808184623],[120.97922140470263,31.60584647663821],[120.97922140470263,31.60584647663821],[120.97928994304615,31.605857211552813]],[[120.97267661621314,31.60341470994767],[120.9728499121397,31.603092012971505]],[[120.9724414697818,31.603686780066468],[120.97267661621314,31.60341470994767]],[[120.97226303226867,31.6041163815337],[120.9724414697818,31.603686780066468]],[[120.97159500845119,31.60498796702991],[120.97189492621187,31.604570594990637],[120.97189492621187,31.604570594990637],[120.97226303226867,31.6041163815337]],[[120.97406348954682,31.60286880123054],[120.97360111167362,31.602624332352327]],[[120.97430851492113,31.603002096805785],[120.97406348954682,31.60286880123054]],[[120.97447509419102,31.603158414976395],[120.97430851492113,31.603002096805785]],[[120.97466773074862,31.603301033830917],[120.97447509419102,31.603158414976395]],[[120.97339204768281,31.60337357201978],[120.97342932623455,31.603328663772675],[120.97342932623455,31.603328663772675],[120.97340655897987,31.602816868927192],[120.97340655897987,31.602816868927192],[120.97360111167362,31.602624332352327]],[[120.96719647321885,31.609366565975005],[120.967364312543,31.60922105978442],[120.967364312543,31.60922105978442],[120.96756213266816,31.608938183466016],[120.96756213266816,31.608938183466016],[120.96761746176242,31.608911257728654]],[[120.96970711647285,31.60869483794598],[120.96994630526999,31.608870885377268],[120.96994630526999,31.608870885377268],[120.97017743707103,31.609031758272916],[120.97017743707103,31.609031758272916],[120.9704476477492,31.609211979547997],[120.9704476477492,31.609211979547997],[120.97074435403276,31.609429256653232],[120.97074435403276,31.609429256653232],[120.97101987237534,31.609635889809358],[120.97101987237534,31.609635889809358],[120.97129009809221,31.60981613981421],[120.97129009809221,31.60981613981421],[120.97165774557523,31.610099750265984],[120.97165774557523,31.610099750265984],[120.97175700913473,31.610058867259877]],[[120.96822737291558,31.608551009650327],[120.9678817800897,31.60894347125957],[120.9678817800897,31.60894347125957],[120.96762420336081,31.609260509857897],[120.96762420336081,31.609260509857897],[120.96742859346406,31.609483293189623],[120.96742859346406,31.609483293189623],[120.96728756893738,31.60975904950674],[120.96728756893738,31.60975904950674],[120.96753026123687,31.609785605502328],[120.96753026123687,31.609785605502328],[120.96782286118112,31.609915635659004],[120.96782286118112,31.609915635659004],[120.96823674417926,31.610177074290206],[120.96823674417926,31.610177074290206],[120.96904544477118,31.610431382755984],[120.96904544477118,31.610431382755984],[120.96938556305264,31.610633010002772],[120.96938556305264,31.610633010002772],[120.96956362109135,31.61099751138568],[120.96956362109135,31.61099751138568],[120.96969480390935,31.611243790518287],[120.96969480390935,31.611243790518287],[120.97046119139901,31.611130522313598]],[[120.96719647321885,31.609366565975005],[120.96693011160697,31.609725236232695],[120.96693011160697,31.609725236232695],[120.96674156011836,31.60987985311158],[120.96674156011836,31.60987985311158],[120.96663676919975,31.6100706342401],[120.96663676919975,31.6100706342401],[120.96655778814409,31.610247656837597]],[[120.96840778435528,31.607654491938483],[120.96796600286986,31.60731076654741],[120.96796600286986,31.60731076654741],[120.9675420669161,31.606964970395705],[120.9675420669161,31.606964970395705],[120.96728983168757,31.60676436336412],[120.96728983168757,31.60676436336412],[120.9669024055487,31.606423001180314],[120.9669024055487,31.606423001180314],[120.9665954208189,31.606638850416793],[120.9665954208189,31.606638850416793],[120.96638938185004,31.606886886822913],[120.96638938185004,31.606886886822913],[120.96607507534584,31.60725032936619],[120.96607507534584,31.60725032936619],[120.96583477871935,31.607572689335697],[120.96583477871935,31.607572689335697],[120.96557772433025,31.60790923367451],[120.96557772433025,31.60790923367451],[120.96519817400444,31.608444852481778],[120.96519817400444,31.608444852481778],[120.96513294008496,31.6084960717625]],[[120.9665954208189,31.606638850416793],[120.96638938185004,31.606886886822913],[120.96638938185004,31.606886886822913],[120.96607507534584,31.60725032936619],[120.96607507534584,31.60725032936619],[120.96583477871935,31.607572689335697],[120.96583477871935,31.607572689335697],[120.96557772433025,31.60790923367451]],[[120.96728756893738,31.60975904950674],[120.96716284297159,31.609964412980883],[120.96716284297159,31.609964412980883],[120.96700160170226,31.610156632619525],[120.96700160170226,31.610156632619525],[120.96684915922536,31.610304398482025],[120.96684915922536,31.610304398482025],[120.96675957615389,31.610407389958013],[120.96675957615389,31.610407389958013],[120.96706363330918,31.610683089455996],[120.96706363330918,31.610683089455996],[120.96710708701676,31.61069555012883]],[[120.9696120062507,31.606938725446124],[120.96970337702886,31.60682346583198],[120.96970337702886,31.60682346583198],[120.96928564215362,31.607269444361716],[120.96928564215362,31.607269444361716],[120.96912578659398,31.607518350511935],[120.96912578659398,31.607518350511935],[120.96890492935393,31.60781128702029],[120.96890492935393,31.60781128702029],[120.96921551504339,31.60833443846984],[120.96921551504339,31.60833443846984],[120.96924047811214,31.60833117117372],[120.96924047811214,31.60833117117372],[120.96927020029266,31.608356445292088],[120.9693055967499,31.6083865445019],[120.9693055967499,31.6083865445019],[120.96944741921685,31.608501933224076],[120.96944741921685,31.608501933224076],[120.96970711647374,31.60869483794598],[120.96970711647374,31.60869483794598],[120.96988361709965,31.608658456883504],[120.96988361709965,31.608658456883504],[120.96997936518765,31.60859290274551],[120.96997936518765,31.60859290274551],[120.97018851384557,31.608617180866766],[120.97018851384557,31.608617180866766],[120.97042878264496,31.60849475676219],[120.97042878264496,31.60849475676219],[120.9706118035019,31.608390071143805],[120.9706118035019,31.608390071143805],[120.9708671598101,31.608277015454494]],[[120.96970711647374,31.60869483794598],[120.96988361709965,31.608658456883504],[120.96988361709965,31.608658456883504],[120.96963658504171,31.608456507572733],[120.96963658504171,31.60845650757258],[120.96969426745164,31.608625855561577]],[[120.9678817800897,31.60894347125957],[120.96762420336081,31.609260509857897],[120.96762420336081,31.609260509857897],[120.96742859346406,31.609483293189623],[120.96742859346406,31.609483293189623],[120.96728756893738,31.60975904950674],[120.96728756893738,31.60975904950674],[120.96753026123687,31.609785605502328]],[[120.9693055967499,31.6083865445019],[120.96944741921685,31.608501933224076],[120.96944741921685,31.608501933224076],[120.96970711647374,31.60869483794598]],[[120.96728983168757,31.60676436336412],[120.9669024055487,31.606423001180314],[120.9669024055487,31.606423001180314],[120.9665954208189,31.606638850416793]],[[120.96890492935393,31.60781128702029],[120.96857503529999,31.6081807193747],[120.96857503529999,31.6081807193747],[120.96857933955162,31.60821524481837],[120.96857933955162,31.60821524481837],[120.96855742199807,31.608245509336825],[120.96853890912415,31.60827107258405]],[[120.96890492935393,31.60781128702029],[120.96874792810847,31.6078611344419],[120.96874792810847,31.6078611344419],[120.96867239769288,31.607968093952618],[120.96867239769288,31.607968093952618],[120.96859935441412,31.60796961982482]],[[120.9696120062507,31.606938725446124],[120.96978451421819,31.606721082781167]],[[120.96583477871935,31.607572689335697],[120.96567105870618,31.607480016057224],[120.96567105870618,31.607480016057224],[120.96546943449697,31.60736255764026],[120.96546943449697,31.60736255764026],[120.96513402954916,31.607380565199975],[120.96513402954916,31.607380565199975],[120.96519732115559,31.607372539505363]],[[120.9704476477492,31.609211979547997],[120.97074435403276,31.609429256653232],[120.97074435403276,31.609429256653232],[120.97104709553705,31.609937153690787],[120.97104709553705,31.609937153690787],[120.97102215780532,31.609938830796967],[120.97102215780532,31.609938830796967],[120.97104415311614,31.609955809001786],[120.97106557952296,31.60997234807078]],[[120.96970337702886,31.60682346583198],[120.96928564215362,31.607269444361716],[120.96928564215362,31.607269444361716],[120.96912578659398,31.607518350511935],[120.96912578659398,31.607518350511935],[120.96890492935393,31.60781128702029]],[[120.97042878264496,31.60849475676219],[120.9706118035019,31.608390071143805]],[[120.97017743707103,31.609031758272916],[120.9702880067863,31.60889583885229],[120.9702880067863,31.60889583885229],[120.97043013510891,31.608729241920805],[120.97043013510891,31.608729241920805],[120.97060791665965,31.608626613878304],[120.97060791665965,31.608626613878304],[120.97077760093205,31.60862611536287]],[[120.9669024055487,31.606423001180314],[120.96730976209045,31.606047516572193],[120.96730976209045,31.606047516572193],[120.96721048868181,31.605943092723912],[120.96721048868181,31.605943092723912],[120.96723300044935,31.605865052173975],[120.96723300044935,31.605865052173975],[120.9672177214691,31.605858796589516]],[[120.9702880067863,31.60889583885229],[120.97043013510891,31.608729241920805]],[[120.97050021926978,31.605654078728787],[120.97013378896715,31.605371040042737],[120.97013378896715,31.605371040042737],[120.96981555694643,31.605160461030017],[120.96981555694643,31.605160461030017],[120.96951094754733,31.604963941028423],[120.96951094754733,31.604963941028423],[120.96918390553482,31.60482149308948]],[[120.9676533602342,31.605663026737083],[120.9679234772127,31.605348574194284],[120.9679234772127,31.605348574194284],[120.96814328741867,31.60558310974352]],[[120.96693011160697,31.609725236232695],[120.96673450026393,31.609597790364738],[120.96673450026393,31.609597790364738],[120.96653889652963,31.609460322598085],[120.96653889652963,31.609460322598085],[120.96632524354371,31.609296815994185],[120.96632524354371,31.609296815994185],[120.96603935360231,31.60915416036182],[120.96603935360231,31.60915416036182],[120.96593231397775,31.60920815999413],[120.96593231397775,31.60920815999413],[120.96599694642755,31.609171321493974],[120.96604969591066,31.60914125608822]],[[120.9675420669161,31.606964970395705],[120.96728983168757,31.60676436336412]],[[120.96684915922536,31.610304398482025],[120.96675957615389,31.610407389958013]],[[120.96822737291558,31.608551009650327],[120.96853890912415,31.60827107258405]],[[120.96716284297159,31.609964412980883],[120.96700160170226,31.610156632619525],[120.96700160170226,31.610156632619525],[120.96684915922536,31.610304398482025]],[[120.96840778435528,31.607654491938483],[120.96874792810847,31.6078611344419]],[[120.96796600286986,31.60731076654741],[120.9675420669161,31.606964970395705]],[[120.97050021926978,31.605654078728787],[120.97054608052159,31.60571269913193],[120.97054608052159,31.60571269913193],[120.97026924661964,31.60617169880142]],[[120.96997936518765,31.60859290274551],[120.97018851384557,31.608617180866766],[120.97018851384557,31.608617180866766],[120.97042878264496,31.60849475676219]],[[120.97017743707103,31.609031758272916],[120.9704476477492,31.609211979547997]],[[120.97024252617132,31.60623749627566],[120.97019633881399,31.606248911179392],[120.97019633881399,31.606248911179392],[120.96978451421819,31.606721082781167]],[[120.97050021926978,31.605654078728787],[120.97054608052159,31.60571269913193]],[[120.97114918694817,31.60589652381056],[120.97085276670977,31.605876406592337],[120.97085276670977,31.605876406592337],[120.97054608052159,31.60571269913193]],[[120.96730976209045,31.606047516572193],[120.96721048868181,31.605943092723912]],[[120.96981555694643,31.605160461030017],[120.96951094754733,31.604963941028423]],[[120.9676533602342,31.605663026737083],[120.96721048868181,31.605943092723912]],[[120.97013378896715,31.605371040042737],[120.96981555694643,31.605160461030017]],[[120.9702880067863,31.60889583885229],[120.97043013510803,31.608729241920805],[120.97043013510803,31.608729241920805],[120.97060791665965,31.608626613878304]],[[120.96488775803367,31.59749180581047],[120.9647570997393,31.597778057350528],[120.9647570997393,31.597778057350528],[120.9646948732069,31.597898339693675],[120.9646948732069,31.597898339693675],[120.96482939018314,31.59835631820112],[120.96482939018314,31.59835631820112],[120.9652243010643,31.598609218932886],[120.9652243010643,31.598609218932886],[120.9658181336971,31.599061106228536],[120.9658181336971,31.599061106228536],[120.9663173214692,31.599306446799893],[120.9663173214692,31.599306446799893],[120.96678699620924,31.59970002608933],[120.96678699620924,31.59970002608933],[120.96727542956725,31.600079999541318],[120.96727542956725,31.600079999541318],[120.96754562857271,31.600278213291585],[120.96754562857271,31.600278213291585],[120.9679094941834,31.60057040238819],[120.9679094941834,31.60057040238819],[120.96822303404558,31.600893316943967],[120.96822303404558,31.600893316943967],[120.9679954230179,31.60119774096873],[120.9679954230179,31.60119774096873],[120.96795147625112,31.60133373861268]],[[120.967421762053,31.60274289223151],[120.9677811298341,31.603059026115233],[120.9677811298341,31.603059026115233],[120.96788497481235,31.603121101540705],[120.96788497481235,31.603121101540705],[120.96828044656566,31.603511003882804],[120.96828044656566,31.603511003882804],[120.96861616873824,31.603818759839122],[120.96861616873824,31.603818759839122],[120.96903497321773,31.604158731536582],[120.96903497321773,31.604158731536582],[120.96934681681,31.604453863589796],[120.96934681681,31.604453863589796],[120.9697283451803,31.604701328396274],[120.9697283451803,31.604701328396274],[120.96973011116212,31.604838580549078],[120.96973011116212,31.604838580549078],[120.96981625382169,31.60491190678718],[120.96981625382169,31.60491190678718],[120.97007474801616,31.604857843535708]],[[120.9677811298341,31.603059026115233],[120.96788497481235,31.603121101540705],[120.96788497481235,31.603121101540705],[120.96828044656566,31.603511003882804],[120.96828044656566,31.603511003882804],[120.96861616873824,31.603818759839122],[120.96861616873824,31.603818759839122],[120.96903497321773,31.604158731536582],[120.96903497321773,31.604158731536582],[120.96934681681,31.604453863589796]],[[120.96721052235694,31.605943100631382],[120.96703932770932,31.605993739149383],[120.96703932770932,31.605993739149383],[120.96698283883164,31.60601160735943]],[[120.96488775803367,31.59749180581047],[120.9647570997393,31.597778057350528]],[[120.96773689207156,31.601411964313417],[120.9674319165461,31.601683071936673]],[[120.96722851298722,31.602591309550927],[120.96713270536877,31.602542237772383],[120.96713270536877,31.602542237772383],[120.9674319165461,31.601683071936673]],[[120.96722851298722,31.602591309550927],[120.96713270536877,31.602542237772383]],[[120.97069177016395,31.605479843439163],[120.97114918694817,31.60589652381056]],[[120.96722079798337,31.601873440187617],[120.9674319165461,31.601683071936673]],[[120.96970711647285,31.60869483794598],[120.96994630526999,31.608870885377268],[120.96994630526999,31.608870885377268],[120.97017743707103,31.609031758272916]],[[120.9691427953827,31.60417350945632],[120.96903497321773,31.604158731536582]],[[120.9702417728136,31.605072894944882],[120.97069177016395,31.605479843439163]],[[120.967421762053,31.60274289223151],[120.9677811298341,31.603059026115233]],[[120.96706102820384,31.60248899674628],[120.96696332882593,31.60246184383467],[120.96696332882593,31.60246184383467],[120.96688182837228,31.60243477591779]],[[120.97524840361318,31.60441439817198],[120.97521247999394,31.604467415722386],[120.97521247999394,31.604467415722386],[120.97517662438436,31.604511198441923],[120.97517662438436,31.604511198441923],[120.97514759469894,31.604571402345233],[120.97514759469894,31.604571402345233],[120.97516063922141,31.604627668865607]],[[120.96674156011836,31.60987985311158],[120.96663676919975,31.6100706342401],[120.96663676919975,31.6100706342401],[120.96642290385209,31.60995637650541],[120.96642290385209,31.60995637650541],[120.96625597425003,31.60986221535071],[120.96625597425003,31.60986221535071],[120.96618523156567,31.609765604430912]],[[120.97697100389937,31.60543240416392],[120.97714417729213,31.60528554991223],[120.97714417729213,31.60528554991223],[120.97710858520514,31.605107732347914],[120.97710858520514,31.605107732347914],[120.97715021655799,31.605077538205517],[120.97715021655799,31.605077538205517],[120.97704986723083,31.604977267156904],[120.97704986723083,31.604977267156904],[120.97702725361678,31.605079069477718]],[[120.97342932623455,31.603328663772675],[120.97340655897987,31.602816868927192]],[[120.96722852982343,31.602591313500287],[120.96706101136942,31.60248899279079],[120.96706101136942,31.60248899279079],[120.96704378915625,31.60255722650982]],[[120.97418756924036,31.603695837799094],[120.97411433948659,31.603829031009003],[120.97411433948659,31.603829031009003],[120.97409694332275,31.603863562504582],[120.97408791358417,31.603881486604177],[120.97408791358417,31.603881486604177],[120.97400063582236,31.604054733985148]],[[120.97521247999394,31.604467415722386],[120.97517662438436,31.604511198441923]],[[120.6284761347399,31.654660538271116],[120.62849366329387,31.654611080615894]],[[120.96706102820384,31.60248899674628],[120.96696332882593,31.60246184383467]],[[120.97368239650015,31.60349938573491],[120.97374633149438,31.603472073695876]],[[120.9691427953827,31.60417350945632],[120.96913731132601,31.604182320927297],[120.96913731132601,31.604182320927297],[120.96912645993338,31.604179977597582],[120.96882930914008,31.60405629969171],[120.96872389468464,31.60414569740648],[120.96862670413407,31.60422057127822],[120.9685778686349,31.60433965416692],[120.96879575552629,31.604449892042286],[120.96880793981487,31.604455342489967],[120.96880793981487,31.604455342489967],[120.96882406109414,31.604463929326407]],[[120.96846988184559,31.602562597249033],[120.9685046148027,31.60255532986743],[120.96857732126804,31.6024176375711],[120.96882104125282,31.602163432050997],[120.96906486694324,31.60193553404135],[120.96873231243065,31.60173900472101],[120.96874906146434,31.60171793870778],[120.96876343250743,31.601689970516396],[120.96876343250743,31.601689970516396],[120.96880651025927,31.601697435824676]],[[120.9688662083836,31.60326532110318],[120.968876252348,31.603257616938702],[120.96901948586519,31.60317901852385],[120.969172739598,31.603009975685282],[120.96940462652738,31.60274568539809],[120.96953941942927,31.602535883906825],[120.96973821016701,31.60230596686061],[120.96987261302668,31.602171721023787],[120.96995255173945,31.60208272850458],[120.97002496781269,31.60199935986369],[120.97007541763745,31.601935014172383],[120.97013831985385,31.601973447857016],[120.97016110651845,31.601984510896138],[120.97016110651845,31.601984510896138],[120.97015894695413,31.602011674100225]],[[120.96787946857623,31.603122970782763],[120.9678305213087,31.603130240057432],[120.9678305213087,31.603130240057432],[120.96781958633143,31.60313509742553],[120.9678299307778,31.603235410916405],[120.96772271516699,31.60332971885981],[120.96751932466691,31.603564549990384],[120.96743305480139,31.60350860556298],[120.96740116204411,31.603542361050668],[120.9672804123263,31.60367922895621],[120.96728961790919,31.603687299623815],[120.96728961790919,31.603687299623815],[120.96731225506629,31.60370321387592]],[[120.96742848074975,31.602086118592524],[120.96743700606632,31.602089422033153],[120.96747992016671,31.602122020436603],[120.9676610914212,31.602269776693397],[120.96784667904609,31.602430826538285],[120.96811011525561,31.602659526825295],[120.96825414138782,31.602534277469772],[120.96834080951335,31.602547466494563],[120.96837074034374,31.60254023496354],[120.96837074034374,31.60254023496354],[120.9684100399558,31.602577214690015]],[[120.96969886224537,31.606826804375725],[120.96970399738834,31.60682826524421],[120.969670572266,31.606805096629607],[120.96963968090388,31.60684530354953],[120.9691845293043,31.606572064630473],[120.96903113639098,31.606438007223122],[120.96886691928516,31.606371239318033],[120.96879820430321,31.606352169020525],[120.96878576244609,31.606347592784683]],[[120.96495028785257,31.60190251382798],[120.96508954548833,31.60190607184323],[120.96508954548833,31.60190607184323],[120.96695829719134,31.602464829335478],[120.96695829719134,31.602464829335478],[120.96685982103124,31.602401172734293]],[[120.9651978299973,31.597264902172796],[120.96521550224126,31.597287661816665],[120.96499668183682,31.597454897670875],[120.96487772285572,31.597495670878637],[120.96487764445348,31.597488715229687],[120.96487764445348,31.597488715229687],[120.96488775803367,31.597486805810526]],[[120.9743142797346,31.604756289230632],[120.97413719416083,31.604706011754416],[120.97413719416083,31.604706011754416],[120.97407592199771,31.60469590473568],[120.97410663191718,31.604646679636236],[120.97410640884304,31.60464675399432],[120.97425490208067,31.604451117684732],[120.97427460847068,31.604435294348324],[120.97427460847068,31.604435294348324],[120.9742544582258,31.604426417420182]],[[120.96704377231913,31.602557222558936],[120.96706084792186,31.602520874124142],[120.96707829075137,31.602483744014272],[120.96707829075137,31.602483744014272],[120.9670629963273,31.60246268413338],[120.9670629963273,31.60246268413338],[120.96704754820415,31.602445380068108],[120.96664909516522,31.602065768405005],[120.96597228061135,31.601426646910173],[120.96565690420377,31.601153891161193],[120.96525516671215,31.60081413717438],[120.96495785616425,31.600573774037464],[120.96495732852618,31.600574144468094],[120.96495732852618,31.600574144468094],[120.96488825617914,31.600616322451312],[120.96370000899836,31.60165062532461],[120.96310184358703,31.602168832799837],[120.96310184358703,31.602168832799837],[120.96305399149787,31.60214662807396],[120.96305783143728,31.60213705889387],[120.96305783143728,31.60213705889387],[120.96305772722641,31.602112561144192],[120.96299859315604,31.602111127884044]],[[120.9671683649848,31.60936578126079],[120.9671575543236,31.609360648339923],[120.96707559983356,31.609313596912404],[120.96691339715485,31.609222829126047],[120.96691016933826,31.609233731127503],[120.96691016933826,31.609233731127578],[120.96690469390717,31.60923469678889]],[[120.97017584805101,31.60196371321208],[120.97013831985385,31.601973447857016],[120.97007541763745,31.601935014172383],[120.97002496781269,31.60199935986369],[120.96995255173945,31.60208272850458],[120.9692452887917,31.601639478778296],[120.96919996454376,31.601767770305877],[120.96906486694324,31.60193553404135],[120.96873231243065,31.60173900472101],[120.96874906146434,31.60171793870778],[120.96883578259944,31.601769994513106],[120.96883578259944,31.601769994513106],[120.96881529931942,31.601697455894026]],[[120.96845600486061,31.602603027554117],[120.96841103290589,31.60260457723832],[120.96840361661074,31.602655540633773],[120.96835336797359,31.602702196022793],[120.96821063671433,31.602760354400957],[120.96835981113189,31.602884397202118],[120.96861140251269,31.603011504094905],[120.96881384438733,31.60314108120948],[120.96881737015177,31.603257222495625],[120.96882183596989,31.603268117936075],[120.96882183596989,31.603268117936075],[120.96884736488475,31.603296139014027]],[[120.97077761777008,31.608626119318004],[120.97085814751411,31.608681412305984]],[[120.97184631363233,31.606187565682088],[120.97240064863837,31.605472972938422],[120.97240064863837,31.605472972938422],[120.97250276772388,31.60548515471213]],[[120.97427327786811,31.604756189219337],[120.97428568474304,31.604747381507927],[120.97428568474304,31.604747381507927],[120.97409183464414,31.604726242863546],[120.9739933100873,31.60487971809838],[120.97399316137029,31.604879495023997],[120.97310344743886,31.60451727785437],[120.9731033173116,31.604517816951034],[120.97293504480363,31.604707244354564],[120.97289691947024,31.604776730581094]],[[120.97428694515125,31.604756222553814],[120.97427264208457,31.604747349703626],[120.97427264208457,31.604747349703626],[120.97423705612319,31.60479309084625],[120.97416139669878,31.60494749555804],[120.97416132234072,31.60494745837888],[120.97407666557997,31.605152835607015],[120.97396988858867,31.605169653442516]],[[120.96692565294391,31.60604348305918],[120.96698282199812,31.606011603404017]],[[120.97368241333369,31.6034393896923],[120.97368784341691,31.603411250128307],[120.97368784341691,31.603411250128307],[120.97369261956165,31.603416022629915],[120.97369261956165,31.603416022629915],[120.97367477082658,31.603417819576773]],[[120.96688179470343,31.60243476800742],[120.96692186602758,31.602659229838178],[120.96692186602758,31.602659229838178],[120.96692635550014,31.602462899022694],[120.96633169829028,31.602459963458863],[120.96633168779795,31.60237814378632]],[[120.97516063947205,31.604627668530885],[120.97514430225934,31.605349865682914],[120.97557919541377,31.60535664367595]],[[120.97085733967803,31.6082749479424],[120.97082494533115,31.608235770532715]],[[120.96743525262674,31.60037720832143],[120.96737879587101,31.600377244820077]],[[120.97534470138208,31.604359329062508],[120.97536183783669,31.604332879244136],[120.97536183783669,31.604332879244136],[120.97536900447835,31.604313838830535]],[[120.97288263507237,31.602834457479997],[120.97281751600426,31.60283425208591]],[[120.9746775037919,31.603303319652337],[120.97475439116299,31.60330292911002]],[[120.9669198210272,31.602401172734293],[120.96696332882593,31.60246184383467]],[[120.97368241333369,31.6034393896923],[120.97374633149438,31.603472073695876]],[[120.96691615093137,31.606468464470087],[120.96690562705732,31.606493644826898]],[[120.96970337702886,31.60682346583198],[120.96984217617077,31.606915726708078],[120.96984217617077,31.606915726708078],[120.96980044635538,31.60689066777169],[120.96974771481163,31.606859002271136],[120.96974771481163,31.606859002271136],[120.96971832368096,31.606828052546092]],[[120.96787946857623,31.603122970782763],[120.9678305213087,31.603130240057432]],[[120.96742123656192,31.6020833711954],[120.96742123656192,31.6020833711954]],[[120.96773689207156,31.601406964313423],[120.96782908158508,31.601415472753008],[120.96782908158508,31.601415472753008],[120.96789179159525,31.601373595423148],[120.96795147625112,31.60133373861268]],[[120.97012321587532,31.605035382503868],[120.97013281249393,31.605011109292622],[120.97013281249393,31.605011109292622],[120.97018818155695,31.605042506155133],[120.9702417728136,31.605072894944882]],[[120.96678699620924,31.59969502608931],[120.96684021636555,31.599666083207328]],[[120.96727844578119,31.600067042197796],[120.96672448785378,31.600383673880998]],[[120.97411433948659,31.603829031009003],[120.97411433948659,31.603829031009003]],[[120.97024252617132,31.60623749627566],[120.97019633881399,31.606248911179392]],[[120.9705188423221,31.611201406452405],[120.97045737429387,31.61116829115493],[120.97039904635459,31.6111368675852],[120.97039904635459,31.6111368675852],[120.97046119139901,31.611130522313598]],[[120.96742123656192,31.6020833711954],[120.96743474171893,31.602066123264375],[120.96744806386124,31.60204910908229],[120.96744806386124,31.60204910908229],[120.96742848074885,31.602086118592524]],[[120.96751806805408,31.600363221727488],[120.96743525242283,31.60037720876083]],[[120.97050664192223,31.608478103524007],[120.97044581403168,31.608477962126216],[120.97038498626603,31.60847782083936],[120.97038498626603,31.60847782083931],[120.97042878264496,31.60849475676219]],[[120.9691760627429,31.604926893296394],[120.96920292894558,31.60486497217258],[120.96923009669112,31.604802356138183],[120.96923009669112,31.604802356138183],[120.96918390553482,31.60482149308948]],[[120.96688179470343,31.60243476800742],[120.96692186602758,31.602659229838178]],[[120.96921551504339,31.60833443846984],[120.96924047811214,31.60833117117372],[120.96924047811214,31.60833117117372],[120.96927020029266,31.608356445292088],[120.9693055967499,31.6083865445019]],[[120.96696332882593,31.60246184383467],[120.9669660139532,31.60238783911309]],[[120.97184631363233,31.606187565682088],[120.9717697326128,31.60628863556024]],[[120.96912578659398,31.607518350511935],[120.96917706957471,31.607542045257404]],[[120.9696120062507,31.606938725446124],[120.96956902137926,31.606912310022807]],[[120.97469191824159,31.60403723266735],[120.97452175531714,31.60405492104812]],[[120.96722079798337,31.601873440187617],[120.96714212308791,31.601870112352646]],[[120.96823674417926,31.610177074290206],[120.96831307829325,31.610159071972298]],[[120.97288263507237,31.602834457479997],[120.97293009682826,31.60300407789961]],[[120.96719647321885,31.609366565975005],[120.9671683649857,31.60936578126079]],[[120.97085733967803,31.6082749479424],[120.97086715999426,31.608277015290785]],[[120.9746775037919,31.603303319652337],[120.97466773042343,31.603301034259886]],[[120.96692565294391,31.60604348305918],[120.96674219481046,31.60604998670973]],[[120.96878820853975,31.60634819985751],[120.96874028176015,31.606375377524422]],[[120.96846988184559,31.602562597249033],[120.9684290392917,31.602577257819686]],[[120.96845600486061,31.602603027554117],[120.96842049753057,31.602577238427894]],[[120.9658177014152,31.596552132421476],[120.96560291986326,31.596629595600387],[120.965212332216,31.59662256080789],[120.9651978468371,31.5972649061219]],[[120.9708581475231,31.608681412305984],[120.97084409431382,31.608619177076875],[120.97084409431382,31.608619177076875],[120.97084354931494,31.608620927921034]],[[120.97017584805101,31.60196371321208],[120.97016302030369,31.602011683567287]],[[120.9688662083836,31.60326532110318],[120.9688439792979,31.603296131287113]],[[120.97294623639543,31.604808262104065],[120.97289691947024,31.604776730581094]],[[120.97402598218069,31.605230171575418],[120.97396988858867,31.605169653442516]],[[120.96820653773582,31.61024438703281],[120.96825390610108,31.610206455524633],[120.96831307829325,31.610159071972298]],[[120.96726376491813,31.60187038394021],[120.96720294393565,31.60187024808719],[120.96714212308791,31.601870112352646]],[[120.96707231536202,31.60591284846989],[120.96707248341434,31.605912785999397],[120.9672177214691,31.605858796589516]],[[120.96702322658645,31.6108052869102],[120.9670661059229,31.61074917646191],[120.96710708701676,31.61069555012883]],[[120.974365679022,31.604024003002113],[120.97452174762397,31.604054919524227],[120.97452175531714,31.60405492104812]],[[120.96661337831664,31.600462031666176],[120.96667488643483,31.60041865420182],[120.96672448785378,31.600383673880998]],[[120.96630686939211,31.609765870897327],[120.96624605041195,31.60976573760379],[120.96618523156567,31.609765604430912]],[[120.96690481139696,31.6066289958867],[120.96690552418585,31.606510715295688],[120.96690562705732,31.606493644826898]],[[120.96753438475285,31.60901887622549],[120.96757602275595,31.608964938017092],[120.96761746176242,31.608911257728654]],[[120.9651007992031,31.607468599123788],[120.96515432278336,31.60741533183498],[120.96519732115559,31.607372539505363]],[[120.968721002652,31.60796989596068],[120.96866017846884,31.607969757835168],[120.96859935441412,31.60796961982482]],[[120.97916548306344,31.605913033913303],[120.97922822889123,31.605884891300327],[120.97928994304615,31.605857211552813]],[[120.96983153419613,31.608599566609225],[120.96976488331093,31.608612331316653],[120.96969426745164,31.608625855561577]],[[120.97262360527807,31.60549957273338],[120.97256318644258,31.605492363671242],[120.97250276772388,31.60548515471213]],[[120.9652545731629,31.60849633423882],[120.96519375655521,31.60849620293921],[120.96513294008496,31.6084960717625]],[[120.97024252617132,31.60623749627566],[120.97025644565917,31.606203220378717],[120.97026924661964,31.60617169880142]],[[120.97175700913563,31.610058867259877],[120.97181668417232,31.610060985355485],[120.97187184898898,31.610062943454306]],[[120.96691980419098,31.60240116878524],[120.96688980419118,31.60240116878524],[120.96685980419142,31.60240116878524]]],//[[[116, 31], [116.0005, 31.001]], [[116.0001, 31.0001], [116.0007, 31.002]]],//坐标
                    attributes: {c: 3, d: 4}//其它属性
                }
            ),
            new egisV2.symbol.EleFillSymbol(
                {
                    devId: 'b20001',//oid，psrid
                    devTypeId: '1988000',//设备类型
                    symbolColor: '#ff0000',//颜色
                    symbolFillColor: '#00ff00',//透明度
                    symbolFillOpacity: 0.5,//透明度
                    coordinates: [[[116, 31], [116.0005, 31], [116.0005, 31.0005], [116, 31.0005], [116, 31]]],//坐标
                    attributes: {c: 3, d: 4}//其它属性
                }
            )
        ]


        function flyToExtent(coordinates) {
            let xmin = Number.POSITIVE_INFINITY;
            let xmax = Number.NEGATIVE_INFINITY;
            let ymin = Number.POSITIVE_INFINITY;
            let ymax = Number.NEGATIVE_INFINITY;
            // let xarr = [];
            // let yarr = [];
            let allCoords = coordinates.flat(4)
            for(let i = 0;i < allCoords.length-2;i+=2){
                let x = allCoords[i]
                let y = allCoords[i+1]
                if(x > xmax){
                    xmax = x
                }
                if(x < xmin){
                    xmin = x
                }

                if(y > ymax){
                    ymax = y
                }
                if(y < ymin){
                    ymin = y
                }
            }
            return [
                [xmin, ymin],
                [xmax, ymax]
            ]
        }

        for (let i = 0; i < 10; i++) {
            for (let j = 0; j < 10; j++) {
                if (j > i) {
                    testDatas.push(
                        new egisV2.symbol.EleTextSymbol({
                                devId: 'a10001xx00' + i + j,//oid，psrid
                                devTypeId: 'text',//设备类型
                                symbolColor: '#ff00ff',//颜色
                                symbolSize: 2,//大小
                                symbolColor: '#ff0000',//颜色
                                symbolScalable: true,
                                symbolText: '测' + '-' + i + '-' + j,//文本
                                coordinates: [116 + 0.00002 * i, 31.0002 + 0.00004 * j],//坐标
                                attributes: {c: 3, d: 4}//其它属性
                            }
                        )
                    )
                } else {
                    testDatas.push(
                        new egisV2.symbol.ElePointSymbol({
                            devId: 'a10001xx' + i + j,//oid，psrid
                            devTypeId: 'point',//设备类型
                            symbolId: "4020290",//符号ID
                            symbolRotate: 20,//旋转角度
                            symbolSize: 5,//大小
                            symbolColor: '#ff0000',//颜色
                            symbolOpacity: 1,//透明度
                            symbolScalable: false,//缩放
                            coordinates: [116 + 0.00001 * i, 31.0002 + 0.00002 * j],//坐标
                            attributes: {a: 1, b: 2}//其它信息
                        })
                    )
                }
            }
        }

        featureLayer.addEleSymbols(testDatas)

        //初始化选择工具
        initSelectTool()
        //初始化捕捉工具
        initSnapTool()
        //给选择工具指定文本数据的类型（对应EleTextSymbol的devTypeId）
        selectTool.setTextSourceId('text')
        map.egis.selectionSet.setAutoFlicker(true)
        //设置选择集的数据源回调
        map.egis.selectionSet.setDataSourceCallback(cb => {
            for (let i = 0; i < testDatas.length; i++) {
                let eleSym = testDatas[i]
                let fea = eleSym._toFeature()
                cb(eleSym.type, fea)
            }
        })
    }

    window.onload = function () {
        loadGeoMap_ms(initPage)
    }

</script>
</body>
</html>
